Skip to content

[ShaderGraph] [2022.1] [Ruby] Bool <-> Vector casts#5718

Merged
joshua-davis merged 8 commits into
masterfrom
sg/bool-cast
Oct 7, 2021
Merged

[ShaderGraph] [2022.1] [Ruby] Bool <-> Vector casts#5718
joshua-davis merged 8 commits into
masterfrom
sg/bool-cast

Conversation

@cdxntchou
Copy link
Copy Markdown

@cdxntchou cdxntchou commented Sep 18, 2021

Purpose of this PR

Fix for https://fogbugz.unity3d.com/f/cases/1359160/

Add bool <-> vector casts:
image


Testing status

Describe what manual/automated tests were performed for this PR

  • Tested that casting bool to a dynamic vector node results in the same vector size as casting a float.
  • Bool cast by itself to a dynamic vector node results in a 1-element vector (float).
  • double checked conversion code in HLSL is correct

Added automated tests:

  • Dynamic slot tests -- allow bool to be connected to dynamic vector slot in all combinations
  • Fixed slot tests -- allow bool to be connected to static vector slot in all combinations
  • Node Tests -- check that conversion from bool --> any vector type produces the correct value

PR ShaderGraph: 🟢
https://yamato.cds.internal.unity3d.com/jobs/902-Graphics/tree/sg%252Fbool-cast/.yamato%252Fall-shadergraph.yml%2523PR_ShaderGraph_trunk/9198270/job/pipeline

master: c722c5d
https://yamato.cds.internal.unity3d.com/jobs/902-Graphics/tree/master/.yamato%252Fall-
shadergraph.yml%2523PR_ShaderGraph_trunk/9173313/job/pipeline

PR HDRP: 🟡 -- failures match master behavior
https://yamato.cds.internal.unity3d.com/jobs/902-Graphics/tree/sg%252Fbool-cast/.yamato%252Fall-hdrp.yml%2523PR_HDRP_trunk/9221605/job/pipeline

master: c722c5d
https://yamato.cds.internal.unity3d.com/jobs/902-Graphics/tree/master/.yamato%252Fall-hdrp.yml%2523PR_HDRP_trunk/9193640/job/pipeline

failures:
HDRP on OSX_Metal_playmode_mono_Linear on version trunk -- non-test failure on both 🟡
HDRP on Linux_Vulkan_playmode_mono_Linear on version trunk -- non-test-failure on both 🟡
https://yamato.cds.internal.unity3d.com/jobs/902-Graphics/tree/master/.yamato%252Fhdrp-linux-vulkan.yml%2523HDRP_Linux_Vulkan_playmode_mono_Linear_trunk/9224677/job
HDRP on Win_DX11_playmode_XR_mono_Linear on version trunk -- green on rerun 🟢

PR URP: 🟡 -- failures match master behavior
https://yamato.cds.internal.unity3d.com/jobs/902-Graphics/tree/sg%252Fbool-cast/.yamato%252Fall-urp.yml%2523PR_URP_trunk/9198473/job/pipeline

master: c722c5d

failures:
URP_Terrain on Android_Vulkan_Standalone_il2cpp_Linear on version trunk -- non-test failure on both 🟡
URP_Foundation on OSX_Metal_playmode_mono_Linear on version trunk -- non-test failure on both after master rerun 🟡
https://yamato.cds.internal.unity3d.com/jobs/902-Graphics/tree/master/.yamato%252Furp_foundation-osx-metal.yml%2523URP_Foundation_OSX_Metal_playmode_mono_Linear_trunk/9227199/job

URP_Foundation on Android_OpenGLES3_Standalone_il2cpp_Linear on version trunk -- green on rerun 🟢
URP_PostPro on OSX_Metal_playmode_mono_Linear on version trunk -- non-test failure on both after master rerun 🟡
https://yamato.cds.internal.unity3d.com/jobs/902-Graphics/tree/master/.yamato%252Furp_postpro-osx-metal.yml%2523URP_PostPro_OSX_Metal_playmode_mono_Linear_trunk/9226818/job

Universal_Stereo on Win__Standalone_mono_Linear on version trunk -- same 1 test failed on both 🟡
ShaderGraph on OSX_Metal_playmode_mono_Linear on version trunk -- non-test failure on both after master rerun 🟡
https://yamato.cds.internal.unity3d.com/jobs/902-Graphics/tree/master/.yamato%252Fshadergraph-osx-metal.yml%2523ShaderGraph_OSX_Metal_playmode_mono_Linear_trunk/9226817/job


Comments to reviewers

Notes for the reviewers you have assigned.

@github-actions
Copy link
Copy Markdown

Hi! This comment will help you figure out which jobs to run before merging your PR. The suggestions are dynamic based on what files you have changed.
Link to Yamato: https://yamato.cds.internal.unity3d.com/jobs/902-Graphics
Search for your PR branch using the sidebar on the left, then add the following segment(s) to the end of the URL (you may need multiple tabs depending on how many packages you change)

Shader Graph
/.yamato%252Fall-shadergraph.yml%2523PR_ShaderGraph_trunk
Depending on your PR, you may also want
/.yamato%252Fall-shadergraph_builtin_foundation.yml%2523PR_ShaderGraph_BuiltIn_Foundation_trunk
/.yamato%252Fall-shadergraph_builtin_lighting.yml%2523PR_ShaderGraph_BuiltIn_Lighting_trunk

Depending on the scope of your PR, you may need to run more jobs than what has been suggested. Please speak to your lead or a Graphics SDET (#devs-graphics-automation) if you are unsure.

@bencloward
Copy link
Copy Markdown
Contributor

I went over this with Alex and we both love it! Thanks a lot for figuring out how to do this.

@cdxntchou
Copy link
Copy Markdown
Author

I went over this with Alex and we both love it! Thanks a lot for figuring out how to do this.

👍

@cdxntchou cdxntchou closed this Sep 21, 2021
@cdxntchou cdxntchou reopened this Sep 21, 2021
case ConcreteSlotValueType.Vector2:
case ConcreteSlotValueType.Vector3:
case ConcreteSlotValueType.Vector4:
return string.Format("((bool) {0}.x)", rawOutput);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this mean that vector -> bool casts only take the x component? Should that be the behavior or should it be using either any/all?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably taking the first one has the least chance of unintentional behavior...

return ordered.FirstOrDefault();
{
var first = ordered.FirstOrDefault();
if (first == ConcreteSlotValueType.Boolean)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't clear to me as you remove Boolean from the list but you handle the case of boolean here. Can this actually happen and if so why?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah the inner case here can be removed, as the outer case handles it. Didn't have the outer check originally, but it's needed to make bool act like Vector1 in terms of allowing upcasts.

@cdxntchou cdxntchou marked this pull request as ready for review October 4, 2021 18:36
@cdxntchou cdxntchou requested a review from a team as a code owner October 4, 2021 18:36
Copy link
Copy Markdown
Contributor

@jessebarker jessebarker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Copy Markdown
Contributor

@joshua-davis joshua-davis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good and the questions I had were answered.

@joshua-davis joshua-davis merged commit 6bc1d8d into master Oct 7, 2021
@joshua-davis joshua-davis deleted the sg/bool-cast branch October 7, 2021 22:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants